<template>
   <el-card>

  
        <h5>修改密码</h5>
        <div class="revamppsd">
        <p> <span>原密码</span>  <el-input v-model="rawpsd" style="width:320px; height:30px"></el-input></p> 
         <p> <span>新密码</span>  <el-input v-model="newpsd" show-password style="width:320px;height:20px;"></el-input> </p> 
         <p>  <span>确认密码</span>    <el-input v-model="input"  show-password  style="width:320px;height:30px"></el-input></p>   
     
        </div>
        <div class="confirm"> <el-button type="primary" @click="dataBtn">确定</el-button>
                <el-button  @click="resetBtn" :plain="true" >重置</el-button></div>
         
  
      </el-card>
  
   
</template>

<script>
// editpwd
import {checkoldpwd,editpwd} from '@/apis/user'
    export default {
        data(){
          return{
       
            rawpsd:'',
            newpsd:'',
            input:''
          }
        },methods:{
          dataBtn(){
        let a=  JSON.parse(localStorage.getItem('uses'))  

           checkoldpwd({oldPwd:this.rawpsd,id:a}).then((res)=>{
      if(res.data.code==0){
        if(this.newpsd!=this.input){
      this.$message.error({
          message: '旧密码不对，或新密码2个不一样',
          duration:2000
          
        })
          return
        }
        editpwd({newPwd:this.newpsd,id:a}).then((res)=>{
         if(res.data.code==0){
            this.$router.push('/')
         }
        })
       }
           })
          },resetBtn(){
            this.rawpsd=''
            this.newpsd=''
            this.input=''
          }
        }
    }
</script>

<style lang="less" scoped>


      h5{
   
        font-size: 15px;
        line-height: 40px;
        padding-left: 20px;
        font-weight: normal;
        border-bottom: 1px solid rgb(235, 232, 232);
      }.revamppsd{
        margin: 15px 20px;
        width: 400px;
        p{
          justify-content: space-between;
          margin-top: 20px;
          text-align: right;
          display: flex;
          span{
            line-height: 38px;
            font-size: 14px;
            color: #455A64;
          }
        }
      }.confirm{
        margin: 20px 0 0 100px;
      }
 
.el-card {
  background-color: #fff;
  height: 360px;
}
</style>